home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / libx11 / include / x11 / xaw / textp.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  8KB  |  223 lines

  1. /*
  2. * $XConsortium: TextP.h,v 1.49 91/05/14 15:20:55 gildea Exp $
  3. */
  4.  
  5.  
  6. /***********************************************************
  7. Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
  8. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  9.  
  10.                         All Rights Reserved
  11.  
  12. Permission to use, copy, modify, and distribute this software and its 
  13. documentation for any purpose and without fee is hereby granted, 
  14. provided that the above copyright notice appear in all copies and that
  15. both that copyright notice and this permission notice appear in 
  16. supporting documentation, and that the names of Digital or MIT not be
  17. used in advertising or publicity pertaining to distribution of the
  18. software without specific, written prior permission.  
  19.  
  20. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  21. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  22. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  23. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  24. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  25. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  26. SOFTWARE.
  27.  
  28. ******************************************************************/
  29.  
  30. #ifndef _XawTextP_h
  31. #define _XawTextP_h
  32.  
  33. #include <X11/Xaw/Text.h>
  34. #include <X11/Xaw/SimpleP.h>
  35.  
  36. /****************************************************************
  37.  *
  38.  * Text widget private
  39.  *
  40.  ****************************************************************/
  41. #define MAXCUT    30000    /* Maximum number of characters that can be cut. */
  42.  
  43. #ifndef abs
  44. #define abs(x)    (((x) < 0) ? (-(x)) : (x))
  45. #endif
  46.  
  47. #define GETLASTPOS  XawTextSourceScan(ctx->text.source, 0, \
  48.                       XawstAll, XawsdRight, 1, TRUE)
  49.  
  50. #define zeroPosition ((XawTextPosition) 0)
  51.  
  52. extern XtActionsRec _XawTextActionsTable[];
  53. extern Cardinal _XawTextActionsTableCount;
  54.  
  55. #define XawLF    0x0a
  56. #define XawCR    0x0d
  57. #define XawTAB    0x09
  58. #define XawBS    0x08
  59. #define XawSP    0x20
  60. #define XawDEL    0x7f
  61. #define XawBSLASH '\\'
  62.  
  63. /* constants that subclasses may want to know */
  64. #define DEFAULT_TEXT_HEIGHT ((Dimension)~0)
  65.  
  66. /* displayable text management data structures */
  67.  
  68. typedef struct {
  69.   XawTextPosition position;
  70.   Position y;
  71.   Dimension textWidth;
  72. } XawTextLineTableEntry, *XawTextLineTableEntryPtr;
  73.  
  74. typedef struct {
  75.     XawTextPosition   left, right;
  76.     XawTextSelectType type;
  77.     Atom*         selections;
  78.     int             atom_count;
  79.     int             array_size;
  80. } XawTextSelection;
  81.  
  82. typedef struct _XawTextSelectionSalt {
  83.     struct _XawTextSelectionSalt    *next;
  84.     XawTextSelection    s;
  85.     char        *contents;
  86.     int            length;
  87. } XawTextSelectionSalt;
  88.  
  89. /* Line Tables are n+1 long - last position displayed is in last lt entry */
  90. typedef struct {
  91.   XawTextPosition     top;    /* Top of the displayed text.        */
  92.   int             lines;    /* How many lines in this table.    */
  93.   XawTextLineTableEntry *info;  /* A dynamic array, one entry per line  */
  94. } XawTextLineTable, *XawTextLineTablePtr;
  95.  
  96.  
  97. typedef struct _XawTextMargin {
  98.   Position left, right, top, bottom;
  99. } XawTextMargin;
  100.  
  101. #define VMargins(ctx) ( (ctx)->text.margin.top + (ctx)->text.margin.bottom )
  102. #define HMargins(ctx) ( (ctx)->text.margin.left + (ctx)->text.margin.right )
  103.  
  104. #define IsPositionVisible(ctx, pos) \
  105.         (pos >= ctx->text.lt.info[0].position && \
  106.          pos < ctx->text.lt.info[ctx->text.lt.lines].position)
  107.  
  108. /*
  109.  * Search & Replace data structure.
  110.  */
  111.  
  112. struct SearchAndReplace {
  113.   Boolean selection_changed;    /* flag so that the selection cannot be
  114.                    changed out from underneath query-replace.*/
  115.   Widget search_popup;        /* The poppup widget that allows searches.*/
  116.   Widget label1;        /* The label widgets for the search window. */
  117.   Widget label2;
  118.   Widget left_toggle;        /* The left search toggle radioGroup. */
  119.   Widget right_toggle;        /* The right search toggle radioGroup. */
  120.   Widget rep_label;        /* The Replace label string. */
  121.   Widget rep_text;        /* The Replace text field. */
  122.   Widget search_text;        /* The Search text field. */
  123.   Widget rep_one;        /* The Replace one button. */
  124.   Widget rep_all;        /* The Replace all button. */
  125. };
  126.     
  127. /* Private Text Definitions */
  128.  
  129. typedef int (*ActionProc)();
  130.  
  131. /* New fields for the Text widget class record */
  132.  
  133. typedef struct {int empty;} TextClassPart;
  134.  
  135. struct text_move {
  136.     int h, v;
  137.     struct text_move * next;
  138. };
  139.  
  140. /* Full class record declaration */
  141. typedef struct _TextClassRec {
  142.     CoreClassPart    core_class;
  143.     SimpleClassPart    simple_class;
  144.     TextClassPart    text_class;
  145. } TextClassRec;
  146.  
  147. extern TextClassRec textClassRec;
  148.  
  149. /* New fields for the Text widget record */
  150. typedef struct _TextPart {
  151.     /* resources */
  152.  
  153.     Widget              source, sink;
  154.     XawTextPosition    insertPos;
  155.     XawTextSelection    s;
  156.     XawTextSelectType    *sarray;       /* Array to cycle for selections. */
  157.     XawTextSelectionSalt    *salt;         /* salted away selections */
  158.     int            options;         /* wordbreak, scroll, etc. */
  159.     int            dialog_horiz_offset; /* position for popup dialog */
  160.     int            dialog_vert_offset;  /* position for popup dialog */
  161.     Boolean        display_caret;         /* insertion pt visible iff T */
  162.     Boolean             auto_fill;           /* Auto fill mode? */
  163.     XawTextScrollMode   scroll_vert, scroll_horiz; /*what type of scrollbars.*/
  164.     XawTextWrapMode     wrap;            /* The type of wrapping. */
  165.     XawTextResizeMode   resize;                 /* what to resize */
  166.     XawTextMargin       r_margin;            /* The real margins. */
  167.     XtCallbackList    unrealize_callbacks; /* used for scrollbars */
  168.     
  169.     /* private state */
  170.  
  171.     XawTextMargin       margin;            /* The current margins. */
  172.     XawTextLineTable    lt;
  173.     XawTextScanDirection extendDir;
  174.     XawTextSelection    origSel;    /* the selection being modified */
  175.     Time        lasttime;        /* timestamp of last processed action */
  176.     Time        time;        /* time of last key or button action */ 
  177.     Position        ev_x, ev_y;        /* x, y coords for key or button action */
  178.     Widget        vbar, hbar;        /* The scroll bars (none = NULL). */
  179.     struct SearchAndReplace * search;/* Search and replace structure. */
  180.     Widget          file_insert;    /* The file insert popup widget. */
  181.     XawTextPosition  *updateFrom;   /* Array of start positions for update. */
  182.     XawTextPosition  *updateTo;        /* Array of end positions for update. */
  183.     int            numranges;        /* How many update ranges there are. */
  184.     int            maxranges;        /* How many ranges we have space for */
  185.     XawTextPosition  lastPos;        /* Last position of source. */
  186.     GC              gc;
  187.     Boolean        showposition;   /* True if we need to show the position. */
  188.     Boolean         hasfocus;       /* TRUE if we currently have input focus.*/
  189.     Boolean        update_disabled; /* TRUE if display updating turned off */
  190.     Boolean         single_char;    /* Single character replaced. */
  191.     XawTextPosition  old_insert;    /* Last insertPos for batched updates */
  192.     short           mult;        /* Multiplier. */
  193.     struct text_move * copy_area_offsets; /* Text offset area (linked list) */
  194.  
  195.     /* private state, shared w/Source and Sink */
  196.     Boolean        redisplay_needed; /* in SetValues */
  197.  
  198. } TextPart;
  199.  
  200. /*************************************************************
  201.  *
  202.  * Resource types private to Text widget.
  203.  *
  204.  *************************************************************/
  205.  
  206. #define XtRScrollMode "ScrollMode"
  207. #define XtRWrapMode "WrapMode"
  208. #define XtRResizeMode "ResizeMode"
  209.  
  210. /****************************************************************
  211.  *
  212.  * Full instance record declaration
  213.  *
  214.  ****************************************************************/
  215.  
  216. typedef struct _TextRec {
  217.     CorePart    core;
  218.     SimplePart    simple;
  219.     TextPart    text;
  220. } TextRec;
  221.  
  222. #endif /* _XawTextP_h */
  223.